﻿using System;
using System.Collections.Generic;
using NetTopologySuite.Algorithm;
using NetTopologySuite.GeometriesGraph;
using NetTopologySuite.GeometriesGraph.Index;

namespace NetTopologySuite.Operation.Overlay
{
	public class EdgeSetNoder
	{
		public EdgeSetNoder(LineIntersector li)
		{
			this._li = li;
		}

		public void AddEdges(IEnumerable<Edge> edges)
		{
			foreach (Edge item in edges)
			{
				this._inputEdges.Add(item);
			}
		}

		public IList<Edge> NodedEdges
		{
			get
			{
				EdgeSetIntersector edgeSetIntersector = new SimpleMCSweepLineIntersector();
				SegmentIntersector si = new SegmentIntersector(this._li, true, false);
				edgeSetIntersector.ComputeIntersections(this._inputEdges, si, true);
				IList<Edge> list = new List<Edge>();
				foreach (Edge edge in this._inputEdges)
				{
					edge.EdgeIntersectionList.AddSplitEdges(list);
				}
				return list;
			}
		}

		private readonly LineIntersector _li;

		private readonly List<Edge> _inputEdges = new List<Edge>();
	}
}
